import React from 'react'
import { useDispatch,useSelector } from 'react-redux'
import{    
  increasecount,
  decreasecount } from '../../stroe/slice/countSlice'

export default function Count() {
    const count  = useSelector(state=>state.count.count)
    const movieList = useSelector(state=>state.movie.movie)
    const dispatch = useDispatch()
    const   increaseOnclick =()=>{
        dispatch(increasecount(10))
    }
    const  decreaseOnclick=()=>{  
      dispatch(decreasecount(3))
    }
    const ifAddincreaseOnclick=()=>{
      if(count%2!==0){
        dispatch(increasecount(1))
      }
    }



  return (
    <div>
        <h1>我是Count组件,我的值是{count}</h1>
        <h5>当前电影总数是{movieList.length}</h5>
        <button onClick={increaseOnclick}>加10</button>
        <button onClick={decreaseOnclick}>加-3</button>
        <button onClick={ifAddincreaseOnclick}>当为计数的时候加1</button>
    </div>
  )
}
